package net.wanho.controller;

import lombok.extern.slf4j.Slf4j;
import net.wanho.bean.SpringBean;
import net.wanho.util.MyUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * Author：汤小洋
 * Date：2024-12-11 15:15
 * Description：<描述>
 */
@Controller
// @CrossOrigin
@Slf4j
public class HelloController {

    @Autowired
    private SpringBean springBean;

    @Autowired
    private SpringBean sb;

    @Value("${shop.name}")
    private String name;

    @Autowired
    private Date date;

    // private final Logger log = LoggerFactory.getLogger(HelloController.class);

    @RequestMapping("/hello")
    @ResponseBody
    public String hello(){
        // System.out.println("hello..........." + ".................." + name);
        // springBean.show();

        // SpringBean sb1 = new SpringBean();
        // SpringBean sb2 = new SpringBean();

        // System.out.println(springBean == sb);


        // MyUtil.print();

        System.out.println("---------------------------------" + date);


        log.info("执行hello方法，正在处理业务功能。。。。。。。。。。。");

        try {
            int i = 5/0;
            log.info("业务执行正常。。。。。。。");
        } catch (Exception e) {
            log.error("业务执行异步。。。。。" + e.getMessage());
            throw new RuntimeException(e);
        }

        return "Hello SpringBoot";
    }

}
